using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Lesson1 : MonoBehaviour
{
    public Transform player = null;
    public Button btnReset;
    public Button btnMove;
    public InputField inputVector;
    public Vector3 tPosition;
    void Start()
    {
        btnReset.onClick.AddListener(()=>
        {
            player.position = Vector3.zero;
        });
        btnMove.onClick.AddListener(()=>
        {
            string strInput = inputVector.text;
            if (strInput == "")
                return;
            string[] stringValues = inputVector.text.Split(',');
            if (stringValues.Length != 3)
            {
                Debug.LogFormat("参数不合法!");
                return;
            }
            float[] floatArray = new float[3];
            for (int i = 0; i < stringValues.Length; i++)
                floatArray[i] = float.Parse(stringValues[i]);
            tPosition = new Vector3(floatArray[0], floatArray[1], floatArray[2]);
            player.position = Vector3.zero;
            player.position = player.position + tPosition;
        });
    }

    void Update()
    {
        // player.position = Vector3.Lerp(player.position, tPosition, Time.deltaTime);
    }
}
